<template>
	<div class="container">
		<div class="jx-return-container">
      <i class="iconfont icon-back" @click="back"></i><span class="cube-title">订单详情</span>
    </div>
    <div class="jx-detail">
      <div class="detail-item">
        <div class="item_2 item">
          <div class="title">
            订单信息
          </div>
          <div class="list">
            <span>客户姓名：</span>
            <div class="right">
              <span>{{detail.consumerLoginname || '--'}}</span>
            </div>
          </div>
          <div class="list">
            <span>客户手机号：</span>
            <div class="right">
              <span>{{detail.mobile || '--'}}</span>
            </div>
          </div>
          <div class="list">
            <span>订单类型：</span>
            <div class="right">
              <span>{{detail.institutionOrderCatalog || '--'}}</span>
            </div>
          </div>
          <div class="list">
            <span>服务单号：</span>
            <div class="right">
              <span>{{detail.voucherNo || '--'}}</span>
            </div>
          </div>
          <div class="list">
            <span>开始时间：</span>
            <div class="right">
              <span>{{detail.voucherValidBeginAt || '--'}}</span>
            </div>
          </div>
          <div class="list">
            <span>结束时间：</span>
            <div class="right">
              <span>{{detail.voucherValidEndAt || '--'}}</span>
            </div>
          </div>
          <div class="list">
            <span>实际消费：</span>
            <div class="right">
              <span>{{detail.sum || '--'}}</span>
            </div>
          </div>
        </div>
        <div class="item_2 item">
          <!-- <div class="title">保单信息</div> -->
          <!-- <div class="list">
            <span>保单类型：</span>
            <div class="right">
              <span>{{detail.voucherValidEndAt || '--'}}</span>
            </div>
          </div>
          <div class="list">
            <span>保单号：</span>
            <div class="right">
              <span>1234242343534534</span>
            </div>
          </div>
          <div class="list">
            <span>赠品价值：</span>
            <div class="right">
              <span>20.00</span>
            </div>
          </div> -->
        </div>
      </div>
      <div class="detail-item">
        <div class="item">
          <div class="title">
            采购明细
          </div>
          <div class="jx-table" style="padding: 0;">
            <el-table :data="detail.uses" border show-summary :summary-method="getSum" style="width: 100%" v-loading="boo.loading">
              <el-table-column type="index" label="序列" width="60" align="center">
              </el-table-column>
              <el-table-column prop="item1" label="产品及服务" width="150" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="item2" label="产品清单" width="130" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="item4" label="适用地区" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="item4" label="数量" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="item5" label="单价" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="item6" label="金额" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="item3" label="服务说明" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-button @click="viewRow(scope.row)" type="text" size="small">查看</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </div>
      <div class="detail-item">
        <div class="item">
          <div class="title">
            使用情况
          </div>
          <div class="jx-table" style="padding: 0;">
            <el-table :data="detail.uses" border style="width: 100%" v-loading="boo.loading">
              <el-table-column type="index" label="序列" width="60" align="center">
              </el-table-column>
              <el-table-column prop="voucherNo" label="服务单编号" width="150" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="shopName" label="服务商家" width="150" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="item3" label="产品及服务" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="item4" label="服务明细" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="voucherOrderAt" label="服务日期" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="item6" label="服务单价" align="center" :show-overflow-tooltip="true">
              </el-table-column>
              <el-table-column prop="item6" label="结算状态" align="center" :show-overflow-tooltip="true">
              </el-table-column>
            </el-table>
          </div>
        </div>
      </div>
    </div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
        https: this.$api.order.list.detail,
        boo: {
          loading: false,
          id: this.$route.query.id,
        },
        other: {
          item4: '0',
          item6: '0',
        },
        detail: '',
			}
		},
		mounted(){
      let _self = this
      _self.getDetail()
    },
		methods: {
      back(){
        history.go(-1)
      },
      getDetail(){
        let _self = this
        let params = {
          id: this.$route.query.id,
        }
        let success = (res)=>{
          res = res.data
          if(res.retCode == 1){
            _self.detail = res.retObject
          }else{
            _self.$message.error(res.retMsg)
          }
        }
        _self.$axios.get(`${_self.https}${params.id}`, {}, success) 
      },
      getSum(param){
        const { columns, data } = param;
        const sums = [];
        columns.forEach((column, index) => {
          if (index === 0) {
            sums[index] = '合计';
            return;
          }
          switch(column.property) {
            case "item4":
              sums[index] = this.other.item4
              break;
            case "item6":
              sums[index] = this.other.item6
              break;
            default:
              break;
          }
        });
        return sums;
      },
      viewRow(){},
    },
	}

</script>
<style scoped lang="sass">
</style>
